package com.tul.exercise.base.swing.components;

import com.tul.exercise.base.swing.SwingConsole;

import javax.swing.*;
import javax.swing.border.TitledBorder;
import javax.swing.plaf.basic.BasicArrowButton;
import java.awt.*;

/**
 * @Description 《java编程思想》第22章 示例13：
 * <p>
 * 按钮组件：
 **/
public class Buttons extends JFrame {
    private JButton jb = new JButton("JButtin");

    private BasicArrowButton up = new BasicArrowButton(BasicArrowButton.NORTH);
    private BasicArrowButton dwon = new BasicArrowButton(BasicArrowButton.SOUTH);
    private BasicArrowButton right = new BasicArrowButton(BasicArrowButton.EAST);
    private BasicArrowButton left = new BasicArrowButton(BasicArrowButton.WEST);

    public Buttons() {
        setLayout(new FlowLayout());

        add(jb);
        add(new JToggleButton("JToggleButton"));
        // 复选框
        add(new JCheckBox("JCheckBox"));
        // 单选框
        add(new JRadioButton("JRadioButton"));

        JPanel jp = new JPanel();
        jp.setBorder(new TitledBorder("Directions"));
        jp.add(up);
        jp.add(dwon);
        jp.add(left);
        jp.add(right);

        add(jp);
    }

    public static void main(String[] args) {
        SwingConsole.run(new Buttons(), 350, 200);
    }
}
